<template>
    <div class="left-nav">
      <div class="nav-logo">
        <span>
          <img src="../assets/logo.png" alt />
          <span v-show="!isCollapse">图书借阅后台管理系统</span>
        </span>
        <el-radio-group v-model="isCollapse" style="margin-bottom: 20px;">
          <i v-show="!isCollapse" class="el-icon-s-fold expandBtn" @click=" isCollapse=true"></i>
          <i v-show="isCollapse" class="el-icon-s-fold shrinkBtn" @click="isCollapse=false"></i>
        </el-radio-group>
      </div>
      <el-menu
        class="el-menu-vertical-demo"
        :unique-opened="true"
        router
        background-color="#151d41"
        text-color="#fff"
        :collapse="isCollapse"
      >
        <el-menu-item index="/">
          <i class="el-icon-s-home"></i>
          <span slot="title">登录</span>
        </el-menu-item>
        <el-submenu v-for="(item,index) in menuList" :index="'' + index" :key="index">
          <template slot="title">
            <i :class="item.icon"></i>
            <span>{{ item.authName }}</span>
          </template>
          <el-menu-item
            v-for="(subItem,index) in item.children"
            :index="'/' + subItem.path"
            :key="index"
          >
            <span>{{ subItem.authName }}</span>
          </el-menu-item>
        </el-submenu>
      </el-menu>
    </div>
  </template>
  
  <script>
  
  export default {
    data() {
      return {
        menuList: [
          {
            id: 0,
            authName: "用户管理",
            icon: "el-icon-s-custom",
            children: [
              {
                authName: "用户管理",
                id: 1,
                path: "home",
                parentid: 0
              },
              { authName: "权限设置", id: 2, path: "Permissions", parentid: 0 }
            ]
          },
          {
            id: 1,
            authName: "图书管理",
            icon: "el-icon-s-claim",
            children: [
              { authName: "图书库存查询", id: 1, path: "bookrecord", parentid: 1 },
              { authName: "图书出入记录", id: 2, path: "bookorder", parentid: 1 }
            ]
          }
        ],
        isCollapse: false
      };
    },
    methods: {}
  };
  </script>
  
  <style lang="less" scoped>
  @bgc: #151d41;
  .left-nav {
    .nav-logo {
      height: 60px;
      padding: 0 10px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      line-height: 60px;
      margin-top: 16px;
      .logo {
        font-size: 30px;
      }
      img {
        width: 28px;
        margin: 5px;
      }
      .el-radio-group {
        font-size: 20px;
        line-height: 60px;
        margin-top: 20px;
        margin-left: 10px;
        .shrinkBtn {
          position: fixed;
          left: -18px;
          top: 38px;
          color: #151d41;
          margin-left: 100px;
          transform: rotate(180deg);
        }
      }
    }
    .el-menu-vertical-demo:not(.el-menu--collapse) {
      width: 200px;
      min-height: 800px;
    }
   
    .el-menu-vertical-demo {
      border: none;
      .el-menu-item {
        span {
          color: #909399;
          font-size: 16px;
        }
      }
      .el-submenu {
        span {
          color: #909399;
          font-size: 16px;
        }
        .el-menu-item {
          span {
            color: #909399;
            font-size: 14px;
          }
        }
      }
    }
  }
  </style>